package com.liuzy.openapi;

import java.net.URLEncoder;

import com.liuzy.tool.HTTP;

/**
 * 有道翻译Api
 * 
 * @author liuzy
 * @since 2016年2月23日
 */
public class YouDaoApi {
	public static String key = "1414374976";
	public static String keyfrom = "myApiProxy";

	@SuppressWarnings("deprecation")
	public static void main(String[] args) {
		fanyi(URLEncoder.encode("你好"));
		fanyi("hello");
	}

	public static String fanyi(String content) {
		HTTP http = new HTTP();
		http.put2url("keyfrom", keyfrom);
		http.put2url("key", key);
		http.put2url("type", "data");
		http.put2url("doctype", "json");// xml json jsonp
		http.put2url("version", "1.1");
		http.put2url("q", content);
		return http.doGET("http://fanyi.youdao.com/openapi.do");
	}
}
